//定义store
import { defineStore } from "pinia";
import { ref } from 'vue'

export const useTokenStore = defineStore('token', () => {
    // 1.响应式变量
    const token = ref('')
    // 2.修改token的值
    const setToken = (newToken) => {
        token.value = newToken
    }
    // 3.删除token的值
    const removeToken = () => {
        token.value = ''
    }

    return {
        token, setToken, removeToken
    }
},
    {
        //持久化存储
        persist: true
    }
)
